package datamark;

import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector;

import java.util.Objects;

/**
 * 3. 自定义AnnotationIntrospector,适配自定义注解返回相应的serialize
 * @author gaofeng
 */
public class DataMaskingAnnotationIntrospector extends NopAnnotationIntrospector {

    @Override
    public Object findSerializer(Annotated am) {
        DataMasking annotation = am.getAnnotation(DataMasking.class);
        if (Objects.nonNull(annotation)) {
            return new DataMaskingSerializer(annotation.maskFunc().operation()) ;
        }
        return null ;
    }
}
